//
//  PickViewController.m
//  Hai
//
//  Created by admin on 16/3/8.
//  Copyright © 2016年 wangzijian. All rights reserved.
//

#import "HeightPickViewController.h"
@interface HeightPickViewController ()
@end

@implementation HeightPickViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    self.pickview.dataSource =self;
    self.pickview.delegate =self;
    [self initPickerData];
    [self pickerView:self.pickview didSelectRow:0 inComponent:0 ];
    [self pickerView:self.pickview didSelectRow:0 inComponent:1 ];
}
//初始化PickerView使用的数据源
-(void)initPickerData{
      [self loaddata];
}

#pragma mark-  加载性别选择数据
- (void)loaddata{
     _arrayData =[[NSMutableArray alloc]init]; 
    for (int i=0; i<100; i++) {
        [_arrayData addObject:[NSString stringWithFormat:@"%i",i]];
    }
     _array2Data =[NSArray arrayWithObjects: @"0.0cm", @"0.1cm", @"0.2cm", @"0.3cm", @"0.4cm", @"0.5cm", @"0.6cm", @"0.7cm", @"0.8cm", @"0.9cm",nil];
}



#pragma mark  --- delegate 视图委托 ---
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
        return 2;
}


- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    if (component == 0){
        return [_arrayData count];
    }else{
        return [_array2Data count];
    }
    
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{
    return 38;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    if (component == 0){
        _data1=_arrayData[row];
        _dataIndex1=[NSString stringWithFormat:@"%i",row];
    }else{
        _data2=_array2Data[row];
        _dataIndex2=[NSString stringWithFormat:@"%i",row];
    }

   
   
}
-(NSString *)pickerView:(UIPickerView *)pickerView
            titleForRow:(NSInteger)row forComponent:(NSInteger)componen{
    if (componen == 0){
         return [_arrayData objectAtIndex:row];
    }else{
         return [_array2Data objectAtIndex:row];
    }  
}

- (IBAction)tapcancel:(id)sender {
//    _dayData=@"1天";
//    _dayDataIndex=@"1";
//    if (([self.dayDataDelegate respondsToSelector:@selector(sendDayData:dayDataIndex:)])) {
//        [self.dayDataDelegate sendDayData:_dayData dayDataIndex:_dayDataIndex];
//    }
    [self removeview];
}
- (IBAction)tapconfirm:(id)sender {
   if (([self.heightDataDelegate respondsToSelector:@selector(sendHeightData:dataIndex1:data2:detaIndex2:)])) {
        [self.heightDataDelegate sendHeightData:_data1 dataIndex1:_dataIndex1 data2:_data2 detaIndex2:_dataIndex2];
    }
    [self removeview];
}
- (IBAction)tapbackground:(id)sender {
//    if (([self.dayDataDelegate respondsToSelector:@selector(sendDayData:dayDataIndex:)])) {
//        [self.dayDataDelegate sendDayData:_dayData dayDataIndex:_dayDataIndex];
//    }
    [self removeview];
}
- (void)removeview{
    [self.view removeFromSuperview];
    [self removeFromParentViewController];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
